<?php $this->load->view('layout/header'); ?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">站点管理</a></li>
            <li><a href="javascript:;">站点公告</a></li>
            <li  class="active"><a href="javascript:;">添加</a></li>
        </ul>
        <div class="product-alls">
            <div class="product-fonter">添加</div>
            <form class="form-horizontal public-validate-form" action="<?php echo site_url('tourismheadline/addPost')?>" method="post" id="tourismtemplet_add">
            	<div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>主题</label>
                    <div class="col-xs-3">
                        <select name="topic_id" class="form-control required">
                            <?php foreach ($topic->result() as $val):?>
                            <option value="<?php echo $val->id;?>"><?php echo $val->name;?></option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>标题</label>
                    <div class="col-xs-10">
                        <input type="text" class="form-control required" name="title">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>内容</label>
                    <div class="col-xs-10">
                        <textarea rows="20" name="content" class="form-control required textarea-multipart-edit"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>状态</label>
                    <div class="col-xs-5">
                        <label class="radio-inline">
                            <input type="radio" name="status" value="1" checked="checked"> 启用
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="status" value="0"> 禁用
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>排序</label>
                    <div class="col-xs-6">
                        <input type="text" class="form-control required number" name="sort" placeholder="数字越小越前" value="50">
                    </div>
                </div>
                <div class="form-btn">
                    <a href="javascript:;">
                        <button class="btn btn-info" >保存</button>
                    </a>
                    <a href="<?php echo site_url('tourismheadline/grid');?>">返回上一步</a>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->load->view('layout/footer'); ?>
<script type="text/javascript">
    if ($('textarea.textarea-multipart-edit').size() > 0) {
        KindEditor.create('textarea.textarea-multipart-edit', {  
            width : '100%',
            height :'400px'
       });
    }
    $('.form-horizontal').submit(function(){
        return false;
    }).validate({
        submitHandler: function(f) {
            var obj = $('button[type=submit]')
            $.ajax({
                type: 'post',
                async: true,
                dataType : 'json',
                url: hostUrl() + '/tourismheadline/addPost',
                data: $('form.form-horizontal').serialize(),
                beforeSend: function() {
                    obj.text('正在保存...').attr('disabled', true);
                },
                success: function(data) {
                    if (data.status) {
                        window.location.href = data.msg;
                    } else {
                        layerMessages(data.status, data.msg);
                    }
                    obj.text('重新保存').removeAttr('disabled');
                }
            });
        }
    });
</script>

